package org.pork.service;

import javax.inject.Inject;

import org.pork.criteria.BbsCriteria;
import org.pork.domain.BbsReplyVO;
import org.pork.domain.BbsVO;
import org.pork.mapper.BbsMapper;
import org.pork.mapper.BbsReplyMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
public class BbsService implements BbsServiceInterface {

	@Inject
	BbsMapper bbsMapper;
	
	@Inject
	BbsReplyMapper bbsReplyMapper;
	
	@Override
	public void regist(BbsVO bVO) {
		
		
		try {
			
			bbsMapper.create(bVO);
		
			
		
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}

	@Override
	@Transactional
	public BbsVO view(Integer seqno) {
		
		BbsVO bbsVO = new BbsVO();
		
		
		try {
			
			bbsVO = bbsMapper.read(seqno);

			bbsMapper.viewCntPlus(seqno);
		
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		
		return bbsVO;
	}

	@Override
	public void remove(Integer seqno) {
		
		try {
			
			bbsMapper.delete(seqno);
			
			
		} catch (Exception e) {
			
			e.printStackTrace();
			
		}
		
	}

	@Override
	public void modify(BbsVO bVO){
		
		try {
			
			bbsMapper.update(bVO);
			
		} catch (Exception e) {
			
			e.printStackTrace();
			
		}
		
	}

	@Override
	public void list(BbsCriteria bCri){
		
		try {
			bbsMapper.list(bCri);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	@Override
	@Transactional
	public void replyRegist(BbsReplyVO bRVO) {
		
		try {
			
			bbsReplyMapper.create(bRVO);
			
			bbsMapper.replyCntPlus(bRVO.getBbsno());
			
		} catch (Exception e) {
			
			e.printStackTrace();
			
		}
		
		
	}

	@Override
	@Transactional
	public void replyRemove(BbsReplyVO bRVO){
		
		try {
			
			bbsReplyMapper.delete(bRVO.getSeqno());
			
			bbsMapper.replyCntMinus(bRVO.getBbsno());
			
		} catch (Exception e) {
			
			e.printStackTrace();
			
		}
		
	}

	@Override
	public void replyModify(BbsReplyVO bRVO){
		
		try {
			
			bbsReplyMapper.update(bRVO);
			
		} catch (Exception e) {
			
			e.printStackTrace();
			
		}
		
	}

	@Override
	public void replyList(Integer bbsNo) {
		
		try {
			
			bbsReplyMapper.list(bbsNo);
			
		} catch (Exception e) {
			
			e.printStackTrace();
			
		}
		
	}

	
}














